package com.shijie99.demo.util;

import java.util.Calendar;
import java.util.Date;

public class DateUtil {
	private static final String[] WEEKDAYS_CN = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
	
	private static final String[] WEEKDAYS_EN = {"sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
	
	public static String getENWeekDay() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());

        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;

        return WEEKDAYS_EN[w];
	}
	
	public static String getCNWeekDay() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());

        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;

        return WEEKDAYS_CN[w];
	}
	
	public static String getCurrentHour() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		
		return String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
	}
	
	public static String getBeforeOneHour() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		
		return String.valueOf(cal.get(Calendar.HOUR_OF_DAY) == 0 
				? 23 : cal.get(Calendar.HOUR_OF_DAY) - 1);
	}
}
